<?php
/**
* Author:陈明标
*/
namespace Home\Model;
use Think\Model\RelationModel;

class UserDepartmentRelationModel extends RelationModel{

    Protected $tableName = 'user';

    Protected $_link = array(
        'department' => array(
            'mapping_type' => self::MANY_TO_MANY,
            'class_name' => 'department',
            'mapping_name' => 'department',
            'foreign_key' => 'user_id',
            'relation_foreign_key' =>'department_id',
            'relation_table' => 'inm_user_department',
            'mapping_fields' => 'id,name,wish',
            'as_fields' => 'name:name'
        ),
        'school' => array(
            'mapping_type' => self::BELONGS_TO,
            'mapping_name' => 'school',
            'foreign_key' => 'school_id',
            'mapping_fields' => 'name',
            'as_fields' => 'name:school_name'
        ),
        'major' => array(
            'mapping_type' => self::BELONGS_TO,
            'mapping_name' => 'major',
            'foreign_key' => 'major_id',
            'mapping_fields' => 'name',
            'as_fields' => 'name:major_name'
        ),

    );

}

?>